package net.muchine.test.spring.data.tutorial.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;

import com.mongodb.Mongo;

@Configuration
public class SpringMongoConfig {

	@Bean
	public MongoDbFactory getMongoDbFactory() throws Exception {
		return new SimpleMongoDbFactory(new Mongo(), "spring");
	}
	
	@Bean
	public MongoTemplate getMongoTemplate() throws Exception {
		return new MongoTemplate(this.getMongoDbFactory());
	}
}
